//-------------------------------------------------------------------------
/**
   File:   EnvironmentString.h

   Descr.: - todo -

   Author: Stefan Leihkauf
   Date:   28.07.2013
*/
//-------------------------------------------------------------------------
#ifndef _ENVIRONMENTSTRING_H
#define _ENVIRONMENTSTRING_H
#include "common/types/typedef.h"

namespace cb { namespace process {

//-------------------------------------------------------------------------
/* Class holding an single environment string.
   A envorinment string is a null terminated key-value pair in the form of
   "key=value".
*/
class EnvironmentString
{
public:
	typedef std::pair<StdString, StdString> KeyValuePair;
	typedef KeyValuePair::first_type KeyType;
	typedef KeyValuePair::second_type ValueType;

	// empty environment string
	static EnvironmentString Empty;

public:
	// construction
	inline EnvironmentString();
	inline EnvironmentString(const KeyValuePair& keyValue);
	inline EnvironmentString(const StdString& key, const StdString& value);

	// set/get key/value pair
	inline void set(const StdString& key, const StdString& value);
	inline const KeyValuePair& get() const;

	// set/get key
	inline const StdString& getName() const;
	inline void setName(const StdString& key);

	// set/get value
	inline const StdString& getValue() const;
	inline void setValue(const StdString& value);

	// equality
	inline bool operator == (const EnvironmentString& other) const;
	inline bool operator != (const EnvironmentString& other) const;

	// string representation ("key=value")
	inline StdString toString() const;

private:
	KeyValuePair _keyvalue;
};
#include "EnvironmentString.hpp"

/* a list of environment name/value pairs*/
typedef std::vector<EnvironmentString> EnvironmentStringList;

}} // namespace cb::process
#endif //!defined _ENVIRONMENTSTRING_H